package controllers

import (
	beego "github.com/beego/beego/v2/server/web"
	"user/models"
)

type UserController struct {
	beego.Controller
}

func (c *UserController) List() {

	var users []models.User
	err := models.DB.Model(&models.User{}).Find(&users).Error
	if err != nil {
		c.Data["json"] = models.JsonR{
			Code: 500,
			Msg:  "展示失败",
			Data: nil,
		}
		c.ServeJSON()
		return
	}
	c.Data["json"] = models.JsonR{
		Code: 200,
		Msg:  "展示成功",
		Data: users,
	}
	c.ServeJSON()
}
